<!--
	o   This page will contain the list of all houses listed for sale by the user
	o   This page allows the user to add/delete/edit new properties
-->

<h1>My Properties Page </h1>

<?php

echo <<<_END

<form action="?page=property-view" method="post">
<input type="hidden" name="add" value="yes"/>
<input type="submit" value="Add new property listing"/>

</form>
<TABLE border=2>
<form name="Result" id="Result" method="POST" action="?page=property-view">
<input type="text" name="PRTID" id="PRTID" value="" hidden="true"/>
	<TR>
		<TH>View</TH>
		<TH>Property Type</TH>
		<TH>Asking Price</TH>
		<TH>Evaluated Price</TH>
		<TH>Year Built</TH>
		<TH>Taxes</TH>
		<TH>Utility Cost</TH>
		<TH>Driveway</TH>
		<TH>Garage</TH>
		<TH>Parking</TH>
		<TH>Zoning</TH>
		<TH>Heating</TH>
		<TH>Cooling</TH>
		<TH>Lot Size</TH>
	</TR>
_END;

include('connect.php');
$query = "SELECT *   FROM LISTS l INNER JOIN PROPERTY p on p.PRTID = l.PRTID   LEFT JOIN (select prtid ,count(*) as ROOMCOUNT from 
ROOMS group by prtid ) r on r.prtid=p.prtid WHERE USRID_SELLS=" . $_SESSION['USRID'] . " ORDER BY l.LISTING_DATE DESC";

$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
while($row = mysql_fetch_assoc($result))
{
  echo('  		
		  <TR>
		  <TD class="center"><a href="#" onclick="document.Result.PRTID.value=\''. $row['PRTID'] .'\' 
;document.Result.submit();">View Property</a></TD>
		  <TD class="center">' . $row['PROPERTY_TYPE'] . '</TD>
		  <TD class="center">' . $row['ASKING_PRICE'] . '$</TD>
		  <TD class="center">' . $row['EVALUATION'] . '$</TD>
		  <TD class="center">' . $row['YEAR_BUILT'] .'</TD>
		  <TD class="center">' . $row['TAXES'] . '$</TD>
		  <TD class="center">' . $row['UTILITY_COSTS'] . '$</TD>
		  <TD class="center">' . $row['DRIVEWAY'] .' Places</TD>
		  <TD class="center">' . $row['GARAGE'] .' Places</TD>
		  <TD class="center">' . $row['PARKING'] .' Places</TD>
		  <TD class="center">' . $row['ZONING'] . '</TD>
		  <TD class="center">' . $row['HEATING_TYPE'] . '</TD>
		  <TD class="center">' . $row['COOLING_TYPE'] . '</TD>
		  <TD class="center">' . $row['LOT_SIZE'] . ' Ft/sq</TD>
		  </TR>
		  
  ');
}
echo' </FORM></TABLE>';
include('disconnect.php');
?>
